package ssm.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ssm.dao.TrackCar;
import ssm.dao.YktCarinfo;
import ssm.model.TrackCarMapper;
import ssm.model.YktCarinfoMapper;

import java.util.HashMap;
import java.util.Map;

@Service
public class CarServiceImpl implements  CarService{
    @Autowired
    private TrackCarMapper trackCarMapper;
    @Autowired
    private YktCarinfoMapper yktCarinfoMapper;

    public Object find(String name) {
        Map<String,Object> map=new HashMap<String,Object>();
        TrackCar car=trackCarMapper.finNewDate(name);
        YktCarinfo carinfo=yktCarinfoMapper.getByCph(name);
        Map<String,Object>base=new HashMap<String,Object>();
        if(carinfo!=null){
            base.put("gh",carinfo.getGh());
            base.put("syrxm",carinfo.getSyrxm());
            base.put("carstatus",carinfo.getCarstatus());
            base.put("enginNum",carinfo.getEnginnum());
            base.put("engineCapacity",carinfo.getEnginecapacity());
            base.put("ratedpassenger",carinfo.getRatedpassenger());
            base.put("carbrand",carinfo.getCarbrand());
            base.put("carcolor",carinfo.getCarcolor());
            base.put("platetype",carinfo.getPlatetype());
            base.put("cartype",carinfo.getCartype());
            base.put("licensetype",carinfo.getLicensetype());
            base.put("plateColor",carinfo.getPlatecolor());
            base.put("license",carinfo.getLicense());
            base.put("imgurl",carinfo.getImgurl());
            base.put("belong",carinfo.getBelong());
        }

        if(car!=null){
            map.put("id",car.getId());
            map.put("cph",car.getCphm());
            map.put("passTime",car.getJgsj());
            map.put("cpys",car.getCpys());
            map.put("zyb",car.getZyb());
            map.put("zpp",car.getZpp());
            map.put("cplx",car.getCplx());
            map.put("clpp",car.getClpp());
            map.put("cllx",car.getCllx());
            map.put("clys",car.getClys());
            map.put("jgdd",car.getJgdd());
            map.put("kkmc",car.getKkmc());
            map.put("cs",car.getCs());
            map.put("cdfx",car.getCdfx());
            map.put("xszt",car.getXszt());
            map.put("sbbh",car.getSbbh());
            map.put("zp",car.getZp());
            map.put("belong",car.getBelong());
            map.put("camerJd",car.getCamerjd());
            map.put("camerWd",car.getCamerwd());
            map.put("locationid",car.getLocationid());
            map.put("deviceid",car.getDeviceid());
            map.put("base",base);
            return map;
        }else{
            return base;
        }

    }
}
